package com.fjrz.bbxwj.mode.api

import com.blankj.utilcode.util.SPStaticUtils
import com.fjrz.bbxwj.app.KEY_NAME_UUID_IMEI
import com.fjrz.bbxwj.entity.CommonPhoneResponse
import com.fjrz.bbxwj.entity.CommonProtocolResponse
import com.fjrz.bbxwj.entity.CommonSplashResponse
import com.module.lemlin.mode.SubscribeListener
import com.module.lemlin.rxhttp.HttpServiceData
import com.module.lemlin.rxhttp.subscribe
import io.reactivex.rxjava3.disposables.Disposable
import rxhttp.RxHttp


/**
 * 协议文本
 *
 * @param key about_us_text关于我们,user_agreement_text用户协议,privacy_policy_text隐私政策,common_problem_text常见问题
 * */
fun commonText(
    key: String, listener: SubscribeListener<CommonProtocolResponse>
): Disposable = subscribe(
    RxHttp.get("/api/common/text")
        .add("key", key)
        .asClass(CommonProtocolResponse::class.java)
    , listener
)

/**
 * 通用数据
 * */
fun commonData(
    listener: SubscribeListener<CommonPhoneResponse>
): Disposable = subscribe(
    RxHttp.get("/api/common/data")
        .asClass(CommonPhoneResponse::class.java)
    , listener
)

/**
 * 评论列表
 *
 * @param city 同城
 * @param limit 条数
 * @param page 分页
 * */
fun commonData(
    videoId: String, page: String, limit: String, listener: SubscribeListener<HttpServiceData>
): Disposable = subscribe(
    RxHttp.get("/api/comment/list")
        .add("video_id", videoId)
        .add("page", page)
        .add("limit", limit)
        .asClass(HttpServiceData::class.java)
    , listener
)


fun commonSplash(
    listener: SubscribeListener<CommonSplashResponse>
): Disposable = subscribe(
    RxHttp.get("/api/common/image")
        .add("key","boot_page")
        .asClass(CommonSplashResponse::class.java)
    , listener
)

fun commonDevice(
   province:String,city:String,listener: SubscribeListener<HttpServiceData>
): Disposable = subscribe(
    RxHttp.get("/api/common/device")
        .add("device_no", SPStaticUtils.getString(KEY_NAME_UUID_IMEI))
        .add("province",province)
        .add("city",city)
        .asClass(HttpServiceData::class.java)
    , listener
)